// --------------------------------------------------------------------------------------------------------------------- 
// <copyright file="ModelFactory.cs" company="Scrum for Team System">
//   None
// </copyright>
// <summary>
//   Defines the ModelFactory type.
// </summary>
// ---------------------------------------------------------------------------------------------------------------------
namespace ScrumForTeamSystem.Metrics
{
    using System;

    /// <summary>
    /// Defines the ModelFactory type.
    /// </summary>
    internal static class ModelFactory
    {
        /// <summary>
        /// Creates an instance of the Trend model.
        /// </summary>
        /// <param name="trendType">Type of the Trend.</param>
        /// <returns>An instance of the Trend model.</returns>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        public static ModelBase CreateModel(TrendType trendType)
        {
            ModelBase output;
            
            switch (trendType)
            {
                case TrendType.None:
                    output = new NullValues();
                    break;
                case TrendType.LinearRegression:
                    output = new LinearRegression();
                    break;
                case TrendType.ThreeDayMovingAverage:
                    output = new MovingAverage(3);
                    break;
                case TrendType.FiveDayMovingAverage:
                    output = new MovingAverage(5);
                    break;
                case TrendType.ThreeDayWeightedMovingAverage:
                    output = new WeightedMovingAverage(3);
                    break;
                case TrendType.FiveDayWeightedMovingAverage:
                    output = new WeightedMovingAverage(5);
                    break;
                case TrendType.ThreeDayExponentialMovingAverage:
                    output = new ExponentialMovingAverage(3);
                    break;
                case TrendType.FiveDayExponentialMovingAverage:
                    output = new ExponentialMovingAverage(5);
                    break;
                case TrendType.ProductLinearRegression:
                    output = new ProductLinearRegression();
                    break;
                default:
                    throw new ArgumentOutOfRangeException("trendType");
            }

            return output;
        }
    }
}